inspector: Add a reset button for settings
authorMatthias Clasen <mclasen@redhat.com>
Thu, 17 Sep 2015 23:14:37 +0000 (19:14 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 4 Oct 2015 02:42:12 +0000 (22:42 -0400)
This is exercising the new gtk_settings_reset_property api.

https://bugzilla.gnome.org/show_bug.cgi?id=755008

gtk/inspector/prop-editor.c

index 32830274543023e3dcc9af118065ca59e9269b0f..0efbfa326a0aae7f9c7b2eafe68a0ad88d4316a0 100644 (file)
@@ -1534,6 +1534,13 @@ add_settings_info (GtkInspectorPropEditor *editor)
   gtk_container_add (GTK_CONTAINER (editor), row);
 }
 
+static void
+reset_setting (GtkInspectorPropEditor *editor)
+{
+  gtk_settings_reset_property (GTK_SETTINGS (editor->priv->object),
+                               editor->priv->name);
+}
+
 static void
 add_gtk_settings_info (GtkInspectorPropEditor *editor)
 {
@@ -1541,6 +1548,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
   const gchar *name;
   GtkWidget *row;
   const gchar *source;
+  GtkWidget *button;
 
   object = editor->priv->object;
   name = editor->priv->name;
@@ -1551,6 +1559,14 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
   row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
   gtk_container_add (GTK_CONTAINER (row), gtk_label_new (_("Source:")));
 
+  button = gtk_button_new_with_label (_("Reset"));
+  g_signal_connect_swapped (button, "clicked", G_CALLBACK (reset_setting), editor);
+
+  gtk_widget_set_halign (button, GTK_ALIGN_END);
+  gtk_widget_show (button);
+  gtk_widget_set_sensitive (button, FALSE);
+  gtk_box_pack_end (GTK_BOX (row), button, FALSE, FALSE, 0);
+
   switch (_gtk_settings_get_setting_source (GTK_SETTINGS (object), name))
     {
     case GTK_SETTINGS_SOURCE_DEFAULT:
@@ -1563,6 +1579,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
       source = _("XSettings");
       break;
     case GTK_SETTINGS_SOURCE_APPLICATION:
+      gtk_widget_set_sensitive (button, TRUE);
       source = _("Application");
       break;
     default: